package algorithm;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class QueueProblem {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int m = in.nextInt();
            Queue<Integer> queue = new LinkedList<>();
            for (int i = 1; i <= m; i++) {
                String[] str = in.nextLine().split(" ");
                if ("push".equals(str[0])) {
                    int n = Integer.parseInt(str[1]);
                    queue.offer(n);
                } else if ("pop".equals(str[0])) {
                    if (queue.isEmpty()) {
                        System.out.println("error");
                    } else {
                        System.out.println(queue.poll());
                    }
                } else if ("front".equals(str[0])) {
                    if (queue.isEmpty()) {
                        System.out.println("error");
                    } else {
                        System.out.println(queue.peek());
                    }
                }

            }
        }
    }
}
